<template>
  <uni-list>
    <uni-list-item
      v-for="item in options"
      :title="item.label || 暂无"
      :note="detailData[item.prop] || 暂无"
    >
    </uni-list-item>
    <uni-list-item
      title="排查结果"
      v-if="detailData.checkInfo"
      :note="detailData.checkInfo"
    >
    </uni-list-item>
  </uni-list>
  <template v-if="detailData.checkState == '未排查'">
    <uni-section title="排查结果" type="line" padding>
      <uni-easyinput
        type="textarea"
        v-model="checkResult"
        placeholder="请输入排查结果"
      ></uni-easyinput>
    </uni-section>
    <button type="primary" @click="onSubmit(checkResult, detailData.id)">
      提 交
    </button>
  </template>
</template>
<script>
export default {
  data() {
    return {
      row: {},
      options: [
        {
          label: "检查计划",
          prop: "governCheckTaskName",
        },
        {
          label: "计划开始时间",
          prop: "governTaskStartTime",
        },
        {
          label: "计划结束时间",
          prop: "governTaskEndTime",
        },
        {
          label: "检查级别",
          prop: "governCheckLevel",
        },
        {
          label: "检查任务类型",
          prop: "governCheckTaskTypeName",
        },
        {
          label: "检查单位",
          prop: "governCheckCompany",
        },
        {
          label: "被检查部门",
          prop: "checkedCompany",
        },
        {
          label: "检查范围",
          prop: "checkRange",
        },
        {
          label: "检查种类",
          prop: "checkKind",
        },
        {
          label: "备注",
          prop: "remark",
        },
        {
          label: "任务完成时间",
          prop: "governTaskCompleteTime",
        },
        {
          label: "任务登记时间",
          prop: "governTaskRegisterTime",
        },
        {
          label: "专项名称",
          prop: "governCheckName",
        },
        {
          label: "专项检查内容",
          prop: "governCheckContent",
        },
        {
          label: "专项检查方式",
          prop: "governCheckWay",
        },
        {
          label: "专项检查依据",
          prop: "governCheckBasis",
        },
        {
          label: "检查时间",
          prop: "governCheckTime",
        },
        {
          label: "检查结果",
          prop: "governCheckResult",
        },
        {
          label: "是否符合",
          prop: "governCheckConform",
        },
      ],
      id: null,
    };
  },
  onLoad(payload) {
    if (payload.row) {
      this.row = JSON.parse(decodeURIComponent(payload.row));
    }
    if (payload.id) {
      this.id = payload.id;
    }
  },
};
</script>
<script setup>
import { apis } from "@/api/yhpc/pcjhrw.js";
import { router } from "@/router/index.js";
import { ref, onMounted, getCurrentInstance } from "vue";
const onSubmit = (checkResult, id) => {
  if (checkResult) {
    apis
      .updateTaskState({
        checkInfo: checkResult,
        // checkState: '已排查',
        id,
      })
      .then((res) => {
        router.back();
      });
  } else {
    uni.showToast({
      title: "请填写排查结果",
      icon: "error",
    });
    return false;
  }
};
const checkResult = ref();
const detailData = ref({});
onMounted(() => {
  const { id, row } = getCurrentInstance().data;
  if (id) {
    apis.detail(id).then((res) => {
      detailData.value = res.data;
    });
  } else {
    detailData.value = row;
  }
});
</script>

<style lang="scss" scoped></style>
